<template>
  <div class="comparison">
    <div class="table">
      <el-table
        v-loading="tableLoading"
        border
        style="width: 100%"
        :cell-style="{ padding: '0px' }"
        :data="tableData"
        :header-cell-style="{
          background: '#0070C0',
          color: '#ffffff',
        }"
      >
        <el-table-column v-for="(item,index) in headerData" :key="index" :label="item" :prop="propsData[index]" align="center">
            <template slot-scope="scope">
                <span>{{scope.row[propsData[index]]}}<span v-if="item == '环比增幅' || item == '季度环比增幅'">%</span></span>
            </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { unitgrouth } from "@/api/barCode/index";
export default {
  name: "comparison",
  components: {},
  props: {
    form: {
      type: Object,
      default: {},
    },
  },
  watch: {
    form: {
      handler() {
        this.getData();
      },
      deep: true,
    },
  },
  data() {
    return {
      tableLoading: false,
      tableData: [],
      headerData: [],
      propsData: []
    };
  },
  computed: {

  },
  created() {},
  mounted() {},
  methods: {
    getData() {
      this.tableLoading = true;
      unitgrouth(this.form).then((res) => {
        if (res.code == 200) {
          this.tableLoading = false;
          this.tableData = res.data.unitgrouth;
          this.headerData = res.data.names;
          this.propsData = res.data.keys;
        }
      });
    },
  },
};
</script>

<style scoped lang="scss">
</style>
